package cn.tedu._01mvcboot01.controller;

import cn.tedu._01mvcboot01.pojo.dto.UserLoginDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class UserController {
    private String username;


    /**
     * 1.GET请求 http://localhost:8080/v1/user/login1?username=Lucy&password=123456
     */
    @GetMapping("/v1/user/login1")
    @ResponseBody
    public String login1(String username,String password){
        System.out.println(username + "------" + password);
        return "登录成功1";
    }
    @PostMapping("/v1/user/login2")
    @ResponseBody
    public String login2(UserLoginDTO userLoginDTO) {
        System.out.println(userLoginDTO);
        return "登录成功2";
    }

    /**
     * bmi健康指数测试:Path中传递数据
     * 测试:http://localhost:8080/bmi/身高/体重
     */

    @GetMapping("/bmi/{height}/{weight}")
    @ResponseBody
    public String bmi(@PathVariable Double height,@PathVariable Double weight){
        double r = weight/(height*height);
        if (r<18.5){
            return "偏瘦";
        }
        if (r<24){
            return "正常";
        }
        if (r<27){
            return "偏胖";
        }
        return "该减肥了";
    }
}
